package lumis.portal.audit;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.NamedQuery;

/**
 * Represents the Audit entry type.
 *
 * @version $Revision: 13093 $ $Date: 2011-05-28 18:40:18 -0300 (Sat, 28 May 2011) $
 * @since 6.0.0
 */
@Entity
@GenericGenerator(name="portal-guid", strategy="lumis.portal.dao.hibernate.GuidGenerator")
@Table(name="lum_AuditEntryType")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@NamedQuery(name = AuditEntryType.NAMED_QUERY_FIND_BY_KEY, query = "select a from AuditEntryType a where a.key = :key", cacheable=true, cacheRegion=IAuditManager.QUERY_CACHE_REGION)
public class AuditEntryType
{
	/**
	 * Name of named query that returns {@link AuditEntryType} 
	 * filtering by parameter <code>key</code>.
	 * @since 6.0.0
	 */
	static final String NAMED_QUERY_FIND_BY_KEY = "findAuditEntryTypeByKey";
	
	/**
	 * The type id.
	 * @since 6.0.0
	 */
	@Id	@GeneratedValue(generator="portal-guid")
	@Column(name="auditEntryTypeId", nullable=false)
	private String id;
	
	/**
	 * The type key.
	 * @since 6.0.0
	 */
	@Column(name="auditEntryTypeKey")
	private String key;
	
	/**
	 * The type key.
	 * @since 6.0.0
	 */
	@Column(name="name")
	private String name;

	/**
	 * The type description.
	 * @since 6.0.0
	 */
	@Column(name="description")
	private String description;

	/**
	 * True if type is enabled, false otherwise.
	 * @since 6.0.0
	 */
	@Column(name="enabled")
	private boolean enabled;
	
	/**
	 * The category of this type.
	 * @since 6.0.0
	 */
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="categoryId")
	private AuditCategory category;

	public String getId()
	{
		return id;
	}
	
	void setId(String id)
	{
		this.id = id;
	}

	public String getKey()
	{
		return key;
	}

	public void setKey(String key)
	{
		this.key = key;
	}

	public String getName()
	{
		return name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public String getDescription()
	{
		return description;
	}

	public void setDescription(String description)
	{
		this.description = description;
	}

	public boolean isEnabled()
	{
		return enabled;
	}

	public void setEnabled(boolean enabled)
	{
		this.enabled = enabled;
	}

	public AuditCategory getCategory()
	{
		return category;
	}

	public void setCategory(AuditCategory category)
	{
		this.category = category;
	}
}